package pe.edu.sistemas.samupg.repository.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import pe.edu.sistemas.samupg.domain.model.Maestria;
import pe.edu.sistemas.samupg.repository.dao.MaestriaDAO;

@Repository
@Transactional
public class MaestriaDAOImpl extends MaestriaDAO {

	@PersistenceContext(unitName = "SAMUPGtomcatPU")
	private EntityManager em;
	
	@Override
	protected EntityManager getEntityManager() {
		return em;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Maestria> findxPeriodoId(int idPeriodo) {
		List<Maestria> maestrias = null;
		String s = "select p.maestrias from Periodo p where p.periodoId = :idPeriodo";
		Query query = em.createQuery(s);
		query.setParameter("idPeriodo", idPeriodo);
		maestrias = query.getResultList();
		return maestrias;
	}
}
